<?php/*  PHP version 5  Copyright (c) 2002-2019ECISP.CN、EarcLink.COM  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030 / 13797552220*/


use modul_application\ESPCMS_MemberAuthority;
use inc_application\link\OrderLink;

class lib_memorder {

	public static function call_memorder($parameter, $filename = 'memorder', $outHTML = null) {
		$espcms_lib_template = espcms_web_template();
		$espcms_lib_template->libfile = true;
		$para = espcms_array_getvalue($parameter);
		$member_cookie_info = ESPCMS_MemberAuthority::getMemberInfo();
		if (!$member_cookie_info['userid'] || !espcms_ismatches($member_cookie_info['userid'])) {
			return false;
		}
		$db_table = ESPCMS_DB_PREFIX . 'order';
		$userid = $member_cookie_info['userid'];
		$order_read = array();

		$order_read['db_num'] = espcms_db_num($db_table, " AND userid=$userid");

		$order_read['db_num_ok'] = espcms_db_num($db_table, " AND userid=$userid AND ordertype=2");

		$db_where = " AND userid=$userid";
		$talbe_field_array = espcms_field_out($db_table, false);
		$array = espcms_db_list_array($db_table, $talbe_field_array, $db_where, "oid DESC", '0,8');
		if (is_array($array) && count($array) > 0) {
			foreach ($array as $key => $value) {
				$array[$key]['link'] = OrderLink::get_order_link('view', $value);
				$array[$key]['paylink'] = OrderLink::get_order_link('pay_ok', $value);
			}
		}
		$espcms_lib_template->into('array', $array);
		$espcms_lib_template->into('order_read', $order_read);
		$espcms_lib_template->into('order_list_link', OrderLink::order_member_link());
		$espcms_lib_template->into('para', $para);
		if (!empty($outHTML)) {
			$output = $espcms_lib_template->fetch(null, null, $outHTML);
		} else {
			$output = $espcms_lib_template->fetch('lib/' . $filename);
		}
		return $output;
	}

}
